9. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2024-03-04 14:38:22 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

9.1 Files compared

#LocationFileLast Modified
1/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme v4.0.7/app/code/Smartwave/Filterproducts/Block/WidgetCarousel.php2023-07-03 06:28:07 +0000
2/Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme v4.0.8/app/code/Smartwave/Filterproducts/Block/WidgetCarousel.php2024-01-15 04:09:21 +0000

9.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged2540
Changed00
Inserted115
Removed00

9.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

9.4 Active regular expressions

No regular expressions were active.

9.5 Comparison detail

1 <?php 1 <?php
2  2 
3 namespace Smartwave\Filterproducts\Block\Widget; 3 namespace Smartwave\Filterproducts\Block\Widget;
4  4 
5 use Magento\Catalog\Api\CategoryRepositoryInterface; 5 use Magento\Catalog\Api\CategoryRepositoryInterface;
6  6 
7  7 
8 class Carousel extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface { 8 class Carousel extends \Magento\Catalog\Block\Product\ListProduct implements \Magento\Widget\Block\BlockInterface {
9  9 
10     protected $_collection; 10     protected $_collection;
11  11 
12     protected $categoryRepository; 12     protected $categoryRepository;
13  13 
14     protected $_resource; 14     protected $_resource;
15  15 
16     protected $_pager; 16     protected $_pager;
17  17 
18     private $serializer; 18     private $serializer;
19  19 
20     const DISPLAY_TYPE_PRODUCTS = 'latest_products'; 20     const DISPLAY_TYPE_PRODUCTS = 'latest_products';
21  21 
22     const DEFAULT_SHOW_PAGER = false; 22     const DEFAULT_SHOW_PAGER = false;
23  23 
24     const DEFAULT_PRODUCTS_PER_PAGE = 5; 24     const DEFAULT_PRODUCTS_PER_PAGE = 5;
25  25 
26     const PAGE_VAR_NAME = 'np'; 26     const PAGE_VAR_NAME = 'np';
27  27 
28     public function __construct( 28     public function __construct(
29         \Magento\Catalog\Block\Product\Context $context, 29         \Magento\Catalog\Block\Product\Context $context,
30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper, 30         \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
31         \Magento\Catalog\Model\Layer\Resolver $layerResolver, 31         \Magento\Catalog\Model\Layer\Resolver $layerResolver,
32         CategoryRepositoryInterface $categoryRepository, 32         CategoryRepositoryInterface $categoryRepository,
33         \Magento\Framework\Url\Helper\Data $urlHelper, 33         \Magento\Framework\Url\Helper\Data $urlHelper,
34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, 34         \Magento\Catalog\Model\ResourceModel\Product\Collection $collection,
35         \Magento\Framework\App\ResourceConnection $resource, 35         \Magento\Framework\App\ResourceConnection $resource,
36         array $data = [], 36         array $data = [],
37         \Magento\Framework\Serialize\Serializer\Json $serializer = null 37         \Magento\Framework\Serialize\Serializer\Json $serializer = null
38     ) { 38     ) {
39         $this->categoryRepository = $categoryRepository; 39         $this->categoryRepository = $categoryRepository;
40         $this->_collection = $collection; 40         $this->_collection = $collection;
41         $this->_resource = $resource; 41         $this->_resource = $resource;
42  42 
43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); 43         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
44  44 
45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() 45         $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46             ->get(\Magento\Framework\Serialize\Serializer\Json::class); 46             ->get(\Magento\Framework\Serialize\Serializer\Json::class);
47     } 47     }
48  48 
    49     /**
    50      * Set template
    51      *
    52      * @return string
    53      */
    54     public function _toHtml()
    55     {
    56         $this->setTemplate(
    57             $this->getData('layout_type') ? 'Smartwave_Filterproducts::widget/'.$this->getData('layout_type').'.phtml' : 'Smartwave_Filterproducts::widget/owl_list.phtml'
    58         );
    59 
    60         $html = parent::_toHtml();
    61         return $html;
    62     }
    63 
49     protected function _beforeToHtml() 64     protected function _beforeToHtml()
50     { 65     {
51         $this->setProductCollection($this->createCollection()); 66         $this->setProductCollection($this->createCollection());
52         return parent::_beforeToHtml(); 67         return parent::_beforeToHtml();
53     } 68     }
54  69 
55     public function createCollection() 70     public function createCollection()
56     { 71     {
57       $category_id = ''; 72       $category_id = '';
58       if($this->getData('category_ids')!=''){ 73       if($this->getData('category_ids')!=''){
59         if(explode('/', $this->getData('category_ids'))[0] == 'category'){ 74         if(explode('/', $this->getData('category_ids'))[0] == 'category'){
60           $category_id = explode('/', $this->getData('category_ids'))[1]; 75           $category_id = explode('/', $this->getData('category_ids'))[1];
61         }else{ 76         }else{
62           $category_id = $this->getData('category_ids'); 77           $category_id = $this->getData('category_ids');
63         } 78         }
64       } 79       }
65       $collection = clone $this->_collection; 80       $collection = clone $this->_collection;
66       $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP); 81       $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP);
67       if(!$category_id) { 82       if(!$category_id) {
68           $category_id = $this->_storeManager->getStore()->getRootCategoryId(); 83           $category_id = $this->_storeManager->getStore()->getRootCategoryId();
69       } 84       }
70       $category = $this->categoryRepository->get($category_id); 85       $category = $this->categoryRepository->get($category_id);
71  86 
72       if ($this->getData('store_id') !== null) { 87       if ($this->getData('store_id') !== null) {
73           $collection->setStoreId($this->getData('store_id')); 88           $collection->setStoreId($this->getData('store_id'));
74       } 89       }
75  90 
76       $collection->addMinimalPrice() 91       $collection->addMinimalPrice()
77           ->addFinalPrice() 92           ->addFinalPrice()
78           ->addTaxPercents() 93           ->addTaxPercents()
79           ->addAttributeToSelect('name') 94           ->addAttributeToSelect('name')
80           ->addAttributeToSelect('image') 95           ->addAttributeToSelect('image')
81           ->addAttributeToSelect('small_image') 96           ->addAttributeToSelect('small_image')
82           ->addAttributeToSelect('thumbnail') 97           ->addAttributeToSelect('thumbnail')
83           ->addAttributeToSelect('special_from_date') 98           ->addAttributeToSelect('special_from_date')
84           ->addAttributeToSelect('special_to_date') 99           ->addAttributeToSelect('special_to_date')
85           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 100           ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
86           ->addUrlRewrite() 101           ->addUrlRewrite()
87           ->addStoreFilter(); 102           ->addStoreFilter();
88  103 
89       if(isset($category) && $category) 104       if(isset($category) && $category)
90       { 105       {
91         $collection->addCategoryFilter($category); 106         $collection->addCategoryFilter($category);
92       } 107       }
93       switch ($this->getDisplayType()) 108       switch ($this->getDisplayType())
94       { 109       {
95           case 'new_products': 110           case 'new_products':
96               $collection->addAttributeToFilter( 111               $collection->addAttributeToFilter(
97                     'news_from_date', 112                     'news_from_date',
98                     ['date' => true, 'to' => $this->getEndOfDayDate()], 113                     ['date' => true, 'to' => $this->getEndOfDayDate()],
99                     'left') 114                     'left')
100                 ->addAttributeToFilter( 115                 ->addAttributeToFilter(
101                     'news_to_date', 116                     'news_to_date',
102                     [ 117                     [
103                         'or' => [ 118                         'or' => [
104                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 119                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
105                             1 => ['is' => new \Zend_Db_Expr('null')], 120                             1 => ['is' => new \Zend_Db_Expr('null')],
106                         ] 121                         ]
107                     ], 122                     ],
108                     'left') 123                     'left')
109                 ->addAttributeToSort( 124                 ->addAttributeToSort(
110                     'news_from_date', 125                     'news_from_date',
111                     'desc'); 126                     'desc');
112               break; 127               break;
113           case 'featured_products': 128           case 'featured_products':
114               $collection->addAttributeToFilter('sw_featured', 1, 'left'); 129               $collection->addAttributeToFilter('sw_featured', 1, 'left');
115               break; 130               break;
116           case 'bestseller_products': 131           case 'bestseller_products':
117               $collection->getSelect() 132               $collection->getSelect()
118                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) 133                   ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty'])
119                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) 134                   ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state'])
120                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") 135                   ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL")
121                   ->group('soi.product_id') 136                   ->group('soi.product_id')
122                   ->order('ordered_qty DESC'); 137                   ->order('ordered_qty DESC');
123               break; 138               break;
124           case 'sale_products': 139           case 'sale_products':
125               $collection->addAttributeToFilter('special_price', ['neq' => '']) 140               $collection->addAttributeToFilter('special_price', ['neq' => ''])
126               ->addAttributeToFilter( 141               ->addAttributeToFilter(
127                     'special_from_date', 142                     'special_from_date',
128                     ['date' => true, 'to' => $this->getEndOfDayDate()], 143                     ['date' => true, 'to' => $this->getEndOfDayDate()],
129                     'left') 144                     'left')
130                 ->addAttributeToFilter( 145                 ->addAttributeToFilter(
131                     'special_to_date', 146                     'special_to_date',
132                     [ 147                     [
133                         'or' => [ 148                         'or' => [
134                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()], 149                             0 => ['date' => true, 'from' => $this->getStartOfDayDate()],
135                             1 => ['is' => new \Zend_Db_Expr('null')], 150                             1 => ['is' => new \Zend_Db_Expr('null')],
136                         ] 151                         ]
137                     ], 152                     ],
138                     'left') 153                     'left')
139                 ->addAttributeToSort( 154                 ->addAttributeToSort(
140                     'news_from_date', 155                     'news_from_date',
141                     'desc'); 156                     'desc');
142               break; 157               break;
143           case 'deal_products': 158           case 'deal_products':
144               $collection->getSelect() 159               $collection->getSelect()
145                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku') 160                   ->joinLeft(['dai' => $collection->getTable('sw_dailydeals_dailydeal')], 'dai.sw_product_sku = e.sku')
146                   ->where('dai.sw_deal_enable=1') 161                   ->where('dai.sw_deal_enable=1')
147                   ->where( 162                   ->where(
148                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL' 163                       'dai.sw_date_from <= "'.$this->getDayDate().'" or dai.sw_date_from IS NULL'
149                   )->where( 164                   )->where(
150                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL' 165                       'dai.sw_date_to >= "'.$this->getDayDate().'" or dai.sw_date_to IS NULL'
151                   ); 166                   );
152               break; 167               break;
153           default: 168           default:
154               $collection->addAttributeToSort('created_at','desc'); 169               $collection->addAttributeToSort('created_at','desc');
155               break; 170               break;
156       } 171       }
157  172 
158       $collection->setPageSize($this->getPageSize()) 173       $collection->setPageSize($this->getPageSize())
159                  ->setCurPage($this->getCurrentPage()); 174                  ->setCurPage($this->getCurrentPage());
160  175 
161       if($this->getDisplayType() == 'featured_products') { 176       if($this->getDisplayType() == 'featured_products') {
162         $collection->getSelect()->order('rand()'); 177         $collection->getSelect()->order('rand()');
163       } 178       }
164       return $collection; 179       return $collection;
165     } 180     }
166  181 
167     public function getCurrentPage() 182     public function getCurrentPage()
168     { 183     {
169         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name'))); 184         return abs((int)$this->getRequest()->getParam($this->getData('page_var_name')));
170     } 185     }
171  186 
172     public function getCacheKeyInfo() 187     public function getCacheKeyInfo()
173     { 188     {
174         return array_merge( 189         return array_merge(
175             parent::getCacheKeyInfo(), 190             parent::getCacheKeyInfo(),
176             [ 191             [
177                 $this->getDisplayType(), 192                 $this->getDisplayType(),
178                 $this->_storeManager->getStore()->getId(), 193                 $this->_storeManager->getStore()->getId(),
179                 $this->getProductsPerPage(), 194                 $this->getProductsPerPage(),
180                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1), 195                 (int) $this->getRequest()->getParam($this->getData('page_var_name'), 1),
181                 $this->serializer->serialize($this->getRequest()->getParams()) 196                 $this->serializer->serialize($this->getRequest()->getParams())
182             ] 197             ]
183         ); 198         );
184     } 199     }
185  200 
186     public function getDisplayType() 201     public function getDisplayType()
187     { 202     {
188         if (!$this->hasData('display_type')) { 203         if (!$this->hasData('display_type')) {
189             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS); 204             $this->setData('display_type', self::DISPLAY_TYPE_PRODUCTS);
190         } 205         }
191         return $this->getData('display_type'); 206         return $this->getData('display_type');
192     } 207     }
193  208 
194     public function getProductsCount() 209     public function getProductsCount()
195     { 210     {
196         if (!$this->hasData('product_count')) { 211         if (!$this->hasData('product_count')) {
197             return parent::getProductsCount(); 212             return parent::getProductsCount();
198         } 213         }
199         return $this->getData('product_count'); 214         return $this->getData('product_count');
200     } 215     }
201  216 
202     public function getProductsPerPage() 217     public function getProductsPerPage()
203     { 218     {
204         if (!$this->hasData('products_per_page')) { 219         if (!$this->hasData('products_per_page')) {
205             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE); 220             $this->setData('products_per_page', self::DEFAULT_PRODUCTS_PER_PAGE);
206         } 221         }
207         return $this->getData('products_per_page'); 222         return $this->getData('products_per_page');
208     } 223     }
209  224 
210     public function showPager() 225     public function showPager()
211     { 226     {
212         return false; 227         return false;
213     } 228     }
214  229 
215     protected function getPageSize() 230     protected function getPageSize()
216     { 231     {
217         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount(); 232         return $this->showPager() ? $this->getProductsPerPage() : $this->getProductsCount();
218     } 233     }
219  234 
220     public function getPagerHtml() 235     public function getPagerHtml()
221     { 236     {
222         if ($this->showPager()) { 237         if ($this->showPager()) {
223             if (!$this->_pager) { 238             if (!$this->_pager) {
224                 $this->_pager = $this->getLayout()->createBlock( 239                 $this->_pager = $this->getLayout()->createBlock(
225                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class, 240                     \Magento\Catalog\Block\Product\Widget\Html\Pager::class,
226                     $this->getWidgetPagerBlockName() 241                     $this->getWidgetPagerBlockName()
227                 ); 242                 );
228  243 
229                 $this->_pager->setUseContainer(true) 244                 $this->_pager->setUseContainer(true)
230                     ->setShowAmounts(true) 245                     ->setShowAmounts(true)
231                     ->setShowPerPage(false) 246                     ->setShowPerPage(false)
232                     ->setPageVarName($this->getData('page_var_name')) 247                     ->setPageVarName($this->getData('page_var_name'))
233                     ->setLimit($this->getProductsPerPage()) 248                     ->setLimit($this->getProductsPerPage())
234                     ->setTotalLimit($this->getProductsCount()) 249                     ->setTotalLimit($this->getProductsCount())
235                     ->setCollection($this->getProductCollection()); 250                     ->setCollection($this->getProductCollection());
236             } 251             }
237             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) { 252             if ($this->_pager instanceof \Magento\Framework\View\Element\AbstractBlock) {
238                 return $this->_pager->toHtml(); 253                 return $this->_pager->toHtml();
239             } 254             }
240         } 255         }
241         return ''; 256         return '';
242     } 257     }
243  258 
244     private function getWidgetPagerBlockName() 259     private function getWidgetPagerBlockName()
245     { 260     {
246         $pageName = $this->getData('page_var_name'); 261         $pageName = $this->getData('page_var_name');
247         $pagerBlockName = 'widget.porto.filter.products.carousel.pager'; 262         $pagerBlockName = 'widget.porto.filter.products.carousel.pager';
248  263 
249         if (!$pageName) { 264         if (!$pageName) {
250             return $pagerBlockName; 265             return $pagerBlockName;
251         } 266         }
252  267 
253         return $pagerBlockName . '.' . $pageName; 268         return $pagerBlockName . '.' . $pageName;
254     } 269     }
255  270 
256     public function getDayDate() 271     public function getDayDate()
257     { 272     {
258         return $this->_localeDate->date()->format('Y-m-d H:i:s'); 273         return $this->_localeDate->date()->format('Y-m-d H:i:s');
259     } 274     }
260  275 
261     public function getStartOfDayDate() 276     public function getStartOfDayDate()
262     { 277     {
263         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s'); 278         return $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s');
264     } 279     }
265  280 
266     public function getEndOfDayDate() 281     public function getEndOfDayDate()
267     { 282     {
268         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s'); 283         return $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s');
269     } 284     }
270 } 285 }